package com.ynkbny.tasks;

import com.ynkbny.aspect.TaskOperationLog;
import com.ynkbny.service.BaseJob;
import com.ynkbny.service.TEpTotalEnergyService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class AutomaticByEnterpriseCode implements BaseJob {

    @Resource
    private TEpTotalEnergyService service;

    /**
     * 单项目电力上报 （上报昨日用电）
     *
     0 15 10 * * ?    每天上午10:15触发
     *
     * @param jobExecutionContext
     * @throws JobExecutionException
     */
    @Override
    @TaskOperationLog(description = "单项目电力上报 （上报昨日用电）")
    public void execute(JobExecutionContext jobExecutionContext) {
        log.info("自动任务：‘单项目电力上报 （上报昨日用电）’ 开始");
        //传递的参数
        JobDataMap data = jobExecutionContext.getTrigger().getJobDataMap();
        log.info("请求参数：{}",data.getString("invokeParam"));
        service.automaticByEnterpriseCode(data.getString("invokeParam"),"3300");
        log.info("自动任务：‘单项目电力上报 （上报昨日用电）’ 结束");
    }
}
